<template>
  <div>
    <el-breadcrumb separator="/">
  <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  <el-breadcrumb-item><a href="/">商品管理</a></el-breadcrumb-item>
  <el-breadcrumb-item>商品列表</el-breadcrumb-item>
</el-breadcrumb>
 <el-input style="margin-top: 15px;" placeholder="请输入内容"  class="input-with-select">
    <el-button slot="append" icon="el-icon-search"></el-button>
  </el-input>
  <el-button type="primary" plain @click="handleAddGoods">添加商品</el-button>
  <template>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
       type="index"
      label="编号"
      height='50'
      width="50">
    </el-table-column>
    <el-table-column
      prop="goods_name"
      label="商品名称"
      hei
      width="400">
    </el-table-column>
    <el-table-column
      prop="goods_price"
      label="商品价格"
      width="100">
    </el-table-column>
    <el-table-column
      prop="city"
      label="商品状态"
      width="100">
    </el-table-column>
    <el-table-column
      prop="goods_weight"
      label="商品重量"
      width="100">
    </el-table-column>
    <el-table-column
      prop="add_time"
      label="创建时间"
      width="120">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      >
      <!-- <template slot-scope="scope"> -->
        <el-button type="primary" icon="el-icon-edit"  plain @click="editUser"></el-button>
         <el-button type="danger" icon="el-icon-delete" plain @click="dellist"></el-button>
         <el-button type="success" icon="el-icon-check" plain></el-button>
      <!-- </template> -->
    </el-table-column>
  </el-table>
</template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </div>
</template>
<script>
import { getGoods } from '@/api'
export default {
  data () {
    return {
      // tableData: [],
      currentPage4: 4,
      formLabelWidth: '120px',
      form: [],
      tableData: []
    }
  },
  created () {
    this.initGoodslist()
  },
  methods: {
    initGoodslist () {
      getGoods({ query: '', pagesize: '20', pagenum: '20' }).then(res => {
        console.log(res)
        this.tableData = res.data.goods
        console.log(this.tableData)
      })
    },
    // 跳转到addgoods页面
    handleAddGoods () {
      this.$router.push({ name: 'addGoods' })
    },
    // 编辑用户
    editUser () {
      // this.$router.push({ name: 'addGoods' })
      this.$router.push({ path: '/addGoods', name: '资源列表', params: { id: 2 } })
      // console.log(this.goods_id)
    },
    // 删除信息
    dellist () {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 页码
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>
<style lang="scss" scoped>
.qwe{
  height: 100px;
}
</style>
